package design.mode.dispatcher.examine;

import design.mode.dispatcher.examine.convert.NumberLetterConverter;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.GZIPOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class Test {
    public static void main(String[] args) {


    }

    private static void zipFile(String filePath, String zipFilePath) throws IOException {
        byte[] buffer = new byte[4096];

        try (FileInputStream fis = new FileInputStream(filePath);
             ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFilePath))) {

            File file = new File(filePath);
            zos.putNextEntry(new ZipEntry(file.getName()));

            int length;
            while ((length = fis.read(buffer)) > 0) {
                zos.write(buffer, 0, length);
            }

            zos.closeEntry();
        }
    }

    private static void moveFile(String sourceFilePath, String targetDirectory) throws IOException {
        File sourceFile = new File(sourceFilePath);
        File targetDirectoryFile = new File(targetDirectory);

        // 创建目标目录（如果不存在）
        if (!targetDirectoryFile.exists()) {
            targetDirectoryFile.mkdirs();
        }

        // 移动文件
        if (sourceFile.exists()) {
            File targetFile = new File(targetDirectoryFile, sourceFile.getName());
            sourceFile.renameTo(targetFile);
        }
    }
}
